package initialize

import (
	"coolcar/api"
	middlewares "coolcar/middleware"
	"net/http"

	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.Cors())

	apiRouter := r.Group("v1")

	apiRouter.GET("healthy", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"msg": "okokok",
		})
	})

	authRouter := apiRouter.Group("auth")
	{
		authRouter.POST("login", middlewares.AuthVerify, api.Login)
	}

	tripRouter := apiRouter.Group("trip")
	{
		tripRouter.POST("", api.CreateTrip)
	}

	return r
}
